#include <stdio.h>
 
int main()
{
    //arr是未知的
    int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
 
    int f = 0;
    printf("输入需要查找数字：\n");
    scanf("%d", &f);
    int sz = sizeof(arr) / sizeof(arr[0]);
    int left = 0;
    int right = sz - 1;
    int mid = 0;
    do
    {
        mid = (left + right) / 2;
        if(arr[mid] == f)
        {
            printf("找到了，位置为：arr[%d]\n", mid);
            break;
        }
        else if(arr[mid] < f)
            {
                left = mid + 1;
                continue;
            }
            else
            {
                right = mid - 1;
                continue;
            }
    } while (left <= right);
    if(left > right)
        printf("没有找到\n");
    return 0;
}